package sevensoft.gz031.demos.web.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import sevensoft.gz031.demos.web.interceptor.AdminInterceptor;

@Configuration
public class SupportConfig extends WebMvcConfigurationSupport {

    @Autowired
    AdminInterceptor adminInterceptor;

    /**
     * 除了登录不拦截其他全部拦截
     * @param registry
     */
    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(adminInterceptor).addPathPatterns("/**").excludePathPatterns("/admin/login");
    }

    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/img").addResourceLocations("D:\\");
    }
}
